/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.letmeshare.stockkeeper.component;

import java.awt.Label;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Date;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.text.DateFormatter;

/**
 *
 * @author Aby
 */
public class DatePanel extends JPanel{

    private ActionListener listener;
    private Label label;
    private JTextField Field;
    private Date date;
    public DatePanel(String title) {
        label=new Label();
        label.setText(title);
        Field=new JTextField();
        Field.addKeyListener(new KeyListener() {

            public void keyTyped(KeyEvent e) {
               
            }

            public void keyPressed(KeyEvent e) {
                
            }

            public void keyReleased(KeyEvent e) {
               if(Field.getText().length()==2 ||Field.getText().length()==5){
                   Field.setText(Field.getText()+"/");
                   isValidDate();
               }
            }
        });
    }
    
    private void isValidDate(){
       if(true){ //validate date.getText()
//           date=DateFormat
//           date.set
       }
    }
    
    
    
}
